<?php
include("../config.php");
include("../include/db_connect.php");
include("../include/session.php");
include("../include/common.php");
include("../include/item.php");
include("../include/search.php");
include("../include/payment.php");

if(isset($_REQUEST['credits']) && isset($_REQUEST['user_id'])) {
	$result = transaction($_REQUEST['user_id'], 0, $_REQUEST['credits'], "Added Credits to account!");
	get_page("message", array("redirect" => "../index.php"));
} else if(isset($_REQUEST['buyer_id']) && isset($_REQUEST['item_id'])) {
	$item = getItem($_REQUEST['item_id']);
	$credits = ceil($item[1][3]/10);
	$result = transaction($_REQUEST['user_id'], 0, $credits, "User bought credits for purchase");
	purchaseItem($_REQUEST['buyer_id'], $_REQUEST['item_id']);
	get_page("message", array("redirect" => "../index.php"));
} else {
	get_page("message", array("redirect" => "../index.php"));
}
?>
